<script type="text/javascript">
	
// 采用辅助空间
function FirstNotRepeatingChar(str)
{
    let obj = {};
  
    for(let i = 0; i <str.length; i++) {
        if(!obj[str[i]]) {
            obj[str[i]] = {}
            obj[str[i]].index = i;
            obj[str[i]].val = 1
        } else {
        	obj[str[i]].val++;
        }
    }
    
    for(let key in obj) {
        if(obj[key].val == 1) return obj[key].index;
    }
    
    return -1;
}

const res = FirstNotRepeatingChar("goole");
console.log(res)

</script>